package org.redr.widgetGUI.core;

import org.redr.widgetGUI.settings.WidgetSettings;
import org.redr.widgetGUI.settings.WidgetState;

import com.trolltech.qt.gui.QLabel;
import com.trolltech.qt.gui.QLayout;
import com.trolltech.qt.gui.QLineEdit;

public class LineEdit extends WidgetState{
	
	private QLineEdit lineEdit;
	
	public QLineEdit widget(){
		return lineEdit;
	}
	
	public LineEdit(LayoutState p, WidgetSettings ws){
		super(p, ws);
		lineEdit = new QLineEdit();
		p.addWidget(new QLabel(_getSetting("label", "!! FIX ME LABEL SHOULD BE SET!!")));
		p.addWidget(lineEdit);
		lineEdit.setText(_getSetting("text", ""));
	}
	
	public LineEdit(QLayout p, WidgetSettings ws) {
		super(p, ws);
		lineEdit = new QLineEdit();
		p.addWidget(new QLabel(_getSetting("label", "!! FIX ME LABEL SHOULD BE SET!!")));
		p.addWidget(lineEdit);
		lineEdit.setText(_getSetting("text", ""));
	}

	public void setText(String t){
		_setSetting("text", t);
		widget().setText(t);
	}
	
	public String text(){
		String t = widget().text();
		// set the state here as we are accessing the setting for processing
		_setSetting("text", t);
		return t;
	}

	public void clear() {
		// TODO Auto-generated method stub
		
	}

}
